package com.msc.controller.thirdpartycontroller;

import com.msc.common.lang.Result;
import com.msc.controller.thirdpartycontroller.vo.HitokotoVo;
import com.msc.thirdparty.bo.HitokotoBo;
import com.msc.thirdparty.HitokotoProvider;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author masc
 * @date 2022-11-28 18:11
 * <p>获取每日一句</p>
 */
@RestController
public class HitokotoController {

    @Autowired
    private HitokotoProvider hitokotoProvider;

    /**
     * 获取每日一句
     */
    @RequestMapping("/hitokoto/dayone")
    @ResponseBody
    public Result getDayone(@RequestParam(defaultValue = "24") String maxLength) {
        HitokotoBo hitokotoInfo = hitokotoProvider.getHitokotoInfo(maxLength);
        HitokotoVo hitokotoVo = new HitokotoVo();
        BeanUtils.copyProperties(hitokotoInfo,hitokotoVo);
        return Result.succ(hitokotoVo);
    }
}
